const express = require('express');
const handle = require('../router_handle/mv_handle');
const app = express.Router();
const multer = require('multer');
const path = require('path');
const storage = multer.diskStorage({
	destination: function (req, file, cb) {
		cb(null, path.join(__dirname, '../uploads/mv'));
	},
	filename: function (req, file, cb) {
		cb(null, 'mv' + new Date().valueOf() + path.extname(file.originalname));
	}
})
const upload = multer({
	storage
})

// 添加mv(post)
// /mv/addMv
// name mvurl mvfile picfile singerId
app.post('/addMv', upload.fields([{
	name: 'mvfile'
}, {
	name: 'picfile'
}]), handle.addMv);
// 删除mv(get)
// /mv/deleteMv
// id
app.get('/deleteMv', handle.deleteMv);
// 查看mv(get)
// /mv/getMv
app.get('/getMv', handle.getMv);
// 通过id查看mv(get)
// /mv/getMvById
// id
app.get('/getMvById', handle.getMvById);
// 通过singerid获取mv(get)
// /mv/getMvBySingerId
// singerid
app.get('/getMvBySingerId', handle.getMvBySingerId);
// 修改mv(post)
// /mv/editMv
// id name mvurl mvfile picfile singerId
app.post('/editMv', upload.fields([{
	name: 'mvfile'
}, {
	name: 'picfile'
}]), handle.editMv);


module.exports = app